<template>
  <div class="appList">
    <!-- 搜索 -->
    <div class="search">
      <span>设备类型</span>
      <el-select v-model="inputType" clearable placeholder="请选择" slot="append" @change="search">
        <el-option v-for="item in options" :key="item.key" :label="item.label" :value="item.value"></el-option>
      </el-select>
    </div>
    <!-- <div class="form_search">
      <el-form :model="formR" @submit.native.prevent>
        <el-input v-model="formR.imei" placeholder="在此输入IMEI编号进行搜索"></el-input>
      </el-form>
      <el-button type="primary" slot="append" @click="condition" class="dev_search">搜索</el-button>
    </div> -->
    <!-- 人员设置 form -->
    <el-row :gutter='24' class='form' id='formt' style='background:#fff; position: relative;'>
      <el-col :span='7'>
        <div class='grid-content'>
          <el-form  :model='formR' label-width='95px' @submit.native.prevent >
            <el-form-item label=' IMEI 号' class='img-name'>
              <el-input v-model='formR.imei'  placeholder="请输入IMEI号" style='width: 200px;' clearable></el-input>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span='7'>
        <div class='grid-content'>
          <el-form  :model='formR' label-width='95px' @submit.native.prevent >
            <el-form-item label='设备ID' class='img-name'>
              <el-input v-model='formR.pushClientId'  placeholder="请输入推送设备ID" style='width: 200px;' clearable></el-input>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span='7'>
        <div class='grid-content'>
          <el-form  :model='formR' label-width='95px' @submit.native.prevent >
            <el-form-item label='列表ID' class='img-name'>
              <el-input v-model='formR.pushListId'  placeholder="请输入列表ID" style='width: 200px;' clearable></el-input>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
      <el-col :span='3' class='btn-cx'>
        <div class='grid-content '>
          <el-form :model='formR' label-width='100px' @submit.native.prevent style="float: right">
            <el-button type='primary' @click="condition" class="search-btn">查询</el-button>
          </el-form>
        </div>
      </el-col>
    </el-row>
    <!-- 表单列表 -->
    <div class="device-manage">
      <el-table :data="listData" stripe :header-cell-style="getRowClass" v-loading="loading">
        <el-table-column prop="num" label="序号" width="80"></el-table-column>
        <el-table-column prop="imei" label="IMEI号" width="200"></el-table-column>
        <el-table-column prop="name" label="用户名称"></el-table-column>
        <el-table-column prop="devname" label="设备类型" width="100">
          <template slot-scope="scope">
            <div style="display: inline;" v-if="scope.row.devname =='fireplug'">消防栓</div>
            <div style="display: inline;" v-if="scope.row.devname =='scm'">烟感设备</div>
          </template>
        </el-table-column>
        <el-table-column prop="phone" label="用户电话"></el-table-column>
        <el-table-column prop="pushClientId" label="推送设备ID" width="200"></el-table-column>
        <el-table-column prop="pushListId" label="推送列表ID"></el-table-column>
        <el-table-column prop="pushContent" label="推送内容"></el-table-column>
        <el-table-column prop="pushResult" label="推送结果"></el-table-column>
        <el-table-column prop="pushResultDetail" label="推送结果详情"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="200"></el-table-column>
        <el-table-column prop="updateTime" label="修改时间" width="200"></el-table-column>
      
      </el-table>
      <page-list
        :size.sync="dev_pageSize"
        :total="totals"
        :current.sync="dev_currentPage"
        @change="getListData"
      ></page-list>
     
    </div>
  </div>
</template>

<script>
import Config from "@/config";
import PageList from "@/components/PageList";
export default {
  name: "DeviceManage",
  components: {
    PageList
  },
  data() {
    return {
      options: [
        {
          value: "",
          label: "全部"
        },
        {
          value: "fireplug",
          label: "消防栓"
        },
        {
          value: "scm",
          label: "烟感设备"
        }
      ],
      inputType: "", // 下拉搜索
      ops: {
        bar: {
          background: "#DDDEE0"
        }
      },
      // 查询
      formR: {},
      // 列表分页
      totals: 0,
      dev_currentPage: 1,
      dev_pageSize: 15,
      inputs: 15,
      //列表
      listData: [],
      // loading
      loading: true,
    };
  },
  methods: {
    // 表头添加背景颜色
    getRowClass({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background:#f6f6f6";
      } else {
        return "";
      }
    },
    // 获取列表
    getListData() {
      this.loading = true;
      let url = `${Config.AUTH_URL}/getFirePlugPushLogByPage?page=${this.dev_currentPage - 1}&size=${this.dev_pageSize}`;
      let params ={
        imei: this.formR.imei ? this.formR.imei : undefined,
        pushListId: this.formR.pushListId ? this.formR.pushListId : undefined,
        pushClientId: this.formR.pushClientId ? this.formR.pushClientId : undefined,
        devname: this.inputType ? this.inputType : undefined
      }
      this.$http.get(url, params).then(res => {
        console.log(res);
        res.content.forEach((item, i) => {
          if (this.dev_currentPage === 1) {
            item.num = i + 1;
          } else {
            item.num = (this.dev_currentPage - 1) * this.dev_pageSize + i + 1;
          }
        });
        this.totals = res.count;
        this.listData = res.content;
        this.loading = false;
      });
    },
    condition(){
      this.dev_currentPage  = 1;
      this.getListData();
    },
    search(){
      this.dev_currentPage  = 1;
      this.getListData();
    },
    
   
  },
  created() {
    this.getListData();
  },
};
</script>

<style lang='scss' >
@import "../../../../static/scss/common.scss";
.appList {
  width: 100%;
  height: 100%;
    // 上方搜索
  .search {
    height: 32px;
    width: 180px;
    display: inline-block;
    background: #fff;
    margin-bottom: 12px;
    text-align: center;
    line-height: 32px;
    > span {
      font-size: 14px;
      color: #333;
      position: relative;
    }
    > span::before {
      position: absolute;
      display: block;
      right: -8px;
      top: 3px;
      content: " ";
      width: 1px;
      height: 16px;
      background: #f0f0f0;
      z-index: 1;
    }
    .el-select {
      width: 104px;
      .el-input--suffix {
        .el-input__inner {
          border: 0;
          border-radius: 0;
          color: #333;
        }
        .el-input__suffix {
          .el-input__suffix-inner {
            .el-input__icon {
              line-height: 32px;
              width: 15px;
            }
          }
        }
      }
    }
  }
  // 搜索
   // 搜索
 .el-input.is-disabled .el-input__inner {
      color: #606266;
      border: 0;
      background-color: #fff;
    }
    .el-row {
      padding: 0;
      .el-col {
        padding: 0 !important;
      }
    }
    .el-form {
      height: 110px;
      display: flex;
      align-items: center;
    }
    .el-form-item.img-name {
      font-family: "微软雅黑";
      font-size: 12px !important;
      font-weight: bold;
      color: #444;
      position: relative;
    }
    .el-form-item__label {
      font-size: 12px !important;
      padding: 0;
      text-align: left;
      text-indent: 51px;
    }
    .img-name /deep/ .el-form-item__label:before {
      position: absolute;
      display: block;
      left: 24px;
      top: 17px;
      content: " ";
      width: 15px;
      height: 20px;
      background: url("/static/image/common/left.png") no-repeat;
    }
    .img-name /deep/ .el-form-item__label:after {
      position: absolute;
      display: block;
      left: 104px;
      top: 17px;
      content: " ";
      width: 20px;
      height: 20px;
      background: url("/static/image/common/right.png") no-repeat;
    }
    .date-picker /deep/ .el-input--prefix .el-input__inner {
      padding-left: 30px;
    }
    .el-form-item.img-name {
      margin: 10px 0 10px 0;
      .el-form-item__label{
        text-align: center;
      }
    }
    .form .el-input__inner {
      height: 28px !important;
      line-height: 28px !important;
      border: 1px solid #e4e4e4;
      padding: 0 0 0 10px!important;
      .el-icon-time{
        line-height: 0;
      }
      .el-range-separator{
        line-height: 25px;
      }
    }
    .form.el-row {
      margin-bottom: 20px;
      &:last-child {
        margin-bottom: 0;
      }
    }












  //列表
  .device-manage {
    width: 100%;
    height: auto;
    background: $white;
    margin-top: 24px;
    .export {
      height: 24px;
      line-height: 24px;
      margin-right: 27px;
      text-align: right;
      padding-top: 12px;
    }
    // 查看
    .dialog-see.el-dialog__wrapper {
      .el-dialog {
        width: 420px;
        height: 366px;
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        margin: auto !important;
        .el-dialog__body {
          .el-form {
            .el-form-item {
              .el-form-item__label {
                line-height: 36px;
              }
              .el-form-item__content {
                line-height: 36px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              }
            }
            //更换设备
            .el-form-item.changesImei {
              .el-form-item__content {
                line-height: 32px;
                .el-input {
                  .el-input__inner {
                    height: 32px;
                    line-height: 32px;
                    width: 260px;
                    border-radius: 0;
                  }
                }
              }
            }
          }
        }
        .el-dialog__footer {
          padding: 30px 0;
          background: $white;
        }
      }
    }
  }
}
</style>
